/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import controller.ClienteController;
import controller.EventoController;

/**
 *
 * @author Myron
 */
public class MainView extends javax.swing.JFrame {

    /**
     * Creates new form MainView
     */
    public MainView() {
        initComponents();
        this.setLocationRelativeTo(null);
        jTabbedPane1.addChangeListener(new ChangeListener() {
			@Override
			public void stateChanged(ChangeEvent e) {
				// TODO Auto-generated method stub
				if(jTabbedPane1.getSelectedIndex() == 0){
					ClienteController.limpaTela(pesquisarClientePanel.txtPesquisaNome, pesquisarClientePanel.txtPesquisaCPF, pesquisarClientePanel.txtPesquisaEmail);
				}
				if(jTabbedPane1.getSelectedIndex() == 1){
					EventoController.limpaTelaPesquisar(pesquisarEventoPanel.txtPesquisaNomeEvento, pesquisarEventoPanel.txtNomeCliente, pesquisarEventoPanel.jdataInicio, pesquisarEventoPanel.jdataFim, pesquisarEventoPanel.txtLogradouro);
				}
				if(jTabbedPane1.getSelectedIndex() == 2){
					EventoController.limpaTelaCadastrar(cadastrarPanel.txtNomeCliente, cadastrarPanel.txtCpfCliente	, cadastrarPanel.ftxtTelefoneCliente, cadastrarPanel.txtEmailCliente,
														cadastrarPanel.txtNomeEmpresa, cadastrarPanel.txtCNPJEmpresa, cadastrarPanel.txtNomeEvento, cadastrarPanel.cbxStatus, 
														cadastrarPanel.jdata, cadastrarPanel.cbxPeriodo, cadastrarPanel.txtQtdPessoas, cadastrarPanel.txtEnderecoEvento,
														cadastrarPanel.ftxtCepEvento, cadastrarPanel.txtComplemento, cadastrarPanel.txtCidadeEvento, cadastrarPanel.cbxCardapio, cadastrarPanel.txtObs);
				cadastrarPanel.btnVoltarActionPerformed(null);
				}
			}
		});
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        mnSair = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SysEvents");
        setPreferredSize(new java.awt.Dimension(900, 700));
        setResizable(false);

        jMenu1.setText("Arquivo");

        mnSair.setText("Sair");
        mnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnSairActionPerformed(evt);
            }
        });
        jMenu1.add(mnSair);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 900, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 456, Short.MAX_VALUE)
        );
        pesquisarClientePanel = new PesquisarClienteView();
        pesquisarEventoPanel = new PesquisarEventoView();
        cadastrarPanel = new CadastrarEventoView(jTabbedPane1);
        jTabbedPane1.add("Pesquisar Cliente", pesquisarClientePanel);
        jTabbedPane1.add("Pesquisar Evento", pesquisarEventoPanel);
        jTabbedPane1.add("Cadastro de Evento", cadastrarPanel);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnSairActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_mnSairActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                System.out.println(info.getName());
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainView().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JMenuItem mnSair;
    private CadastrarEventoView cadastrarPanel;
    private PesquisarClienteView pesquisarClientePanel;
    private PesquisarEventoView pesquisarEventoPanel;
    // End of variables declaration//GEN-END:variables
}
